cmake_minimum_required(VERSION 3.9)

project(sqlite3 VERSION 1.0 LANGUAGES C)

set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)

# 选项：是否编译为共享库
option(BUILD_SHARED_LIBS "Build shared library instead of static" OFF)

# 宏定义
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_CORE=1")

# 包含目录
include_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}/src
)

# 源文件
file(GLOB SQLITE_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c")
# 过滤掉所有文件名里包含 "test"
list(FILTER SQLITE_SOURCES EXCLUDE REGEX ".*test.*\\.c$")

# 生成库
add_library(sqlite3 ${SQLITE_SOURCES})

# 输出名保持一致
set_target_properties(sqlite3 PROPERTIES OUTPUT_NAME "sqlite3")
